#
# Copyright (c) 2008 - Coaxial IT Services. All Rights Reserved
#
# @author Giancarlo Bellido
#

module Ph
  
  class Router
		
		attr_reader :routes

		def initialize
			@routes = Hash.new
		end
   
	 	def route(env)
			
			null, type, res, *params = env['REQUEST_URI'].split('/')

			case type
			when 'data'
				resource = @routes[res.to_sym]
				env[:parameters] = params
				return resource.new.request(env) if resource
			end

			404

		end
    
  end
  
end
